package org.Test;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.JsonMsg.Post;
import org.Panel.MainPanel;
import org.Tools.OnLineOP;
import org.Tools.StringOP;

import javax.swing.*;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        OnLineOP op = new OnLineOP();

//        StringOP op1 = new StringOP();
//        String msg = "[Post(postId=6, userId=2, title=测试2, content=呵呵呵呵, createdAt=2024-12-20 17:23:53.0, updatedAt=2024-12-20 21:40:04.0, likesCount=1, repliesCount=0)]";
//        msg = op1.JsonStr(msg);
//        System.out.println(msg);
//
//        Gson gson = new Gson();
//        // 由于要解析为List<Post>类型，需要使用TypeToken来获取准确的类型信息
//        Type listType = new TypeToken<List<Post>>() {}.getType();
//        List<Post> postList = gson.fromJson(msg, listType);
//        for (Post post : postList) {
//            System.out.println("Post ID: " + post.getPostId());
//            System.out.println("User ID: " + post.getUserId());
//            System.out.println("Title: " + post.getTitle());
//            System.out.println("Content: " + post.getContent());
//            System.out.println("Created At: " + post.getCreatedAt());
//            System.out.println("Updated At: " + post.getUpdatedAt());
//            System.out.println("Likes Count: " + post.getLikesCount());
//            System.out.println("Replies Count: " + post.getRepliesCount());
//            System.out.println("---------------------------");
//        }

        //"reply-{\"postId\":6,\"\":\"\",}-jtd";
        String msg = "deletePostSt-10-jtd";
        System.out.println(msg);
        String ans= null;

        try {
            ans = op.sendone(msg);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        System.out.println(ans);

//        int a= Integer.parseInt("");
//        int b=13;
//        System.out.println(a+b);
    }
}
